package me.algo.array;

import java.util.Objects;

/**
 * @author guozheng
 * @date 2024/4/23
 */
public class A8 {
    public static void main(String[] args) {

    }

    /**
     * 11. 盛最多水的容器
     * @param height
     * @return
     */
    public int maxArea(int[] height) {
        if (Objects.isNull(height) || height.length < 2) {
            return 0;
        }
        int sq = 0;
        for (int i = 0; i < height.length; i++) {
            for (int j = i + 1; j < height.length; j++) {
                int len = j - i + 1;
                int h = Math.min(height[j], height[i]);
                int s = len * h;
                if (s > sq) {
                    sq = s;
                }
            }
        }
        return sq;
    }
}
